<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>1.axios的基本使用</title>
</head>
<body>

<button id="btn">发送axios请求</button>

<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/1.10.1/jquery.js"></script>
<script>

    let user ={
        username: "Alice",
        age: 28,
        country: "Anhui"
    }
     // $("#btn").click(()=> {
         //     axios({
         //         url:'http://127.0.0.1/axios/get',
         //         method:'GET',
         //         params:{name:"Alice",age:1000}
         //     }).then(
         //         response =>{
         //             console.log(response.data);
         //         },
         //         error =>{
         //             console.log(error)
         //         }
         //     )
         // })

     /*  $("#btn").click(()=>{
          //请求行参数使用params
         axios.get("http://127.0.0.1/axios/get", {params: {username: "Jack", age: 19}})
              .then(
                  response => {
                      console.log(response.data)
                  },
                  error => {
                      console.log(error);
                  }
              )

      })*/

     $("#btn").click(()=>{
        //  请求体参数直接添加
         axios.post("http://127.0.0.1/axios/post",user).then(
             response =>{
                 console.log(response.data);
             },
             error =>{
                 console.log(error);
             }
         )
     })






</script>



</body>
</html>